package me.zk.practice1.hw;

import java.util.Arrays;
import java.util.Scanner;

public class HWBJ48 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] nums = Arrays.stream(scanner.nextLine().split(",")).mapToInt(Integer::parseInt).toArray();
        int n = Integer.parseInt(scanner.nextLine());

        int max = Integer.MIN_VALUE;

        int l = 0;
        int r= 0;
        int sum = 0;
        while (r < nums.length) {
            sum += nums[r];
            r++;
            if (r - l ==n) {
                max = Math.max(max, sum);
                sum -= nums[l];
                l++;
            }

        }
        System.out.println(max);

    }
}
